﻿Imports System.Data.SqlClient

Public Class clsEvaluacionTotales
    Private mintidEvaluacionTotales As Integer
    Private mintEvaluacion As Integer
    Private mstrMes As String
    Private mintAnio As Integer
    Private mintLicencia As Double
    Private mintTarjeton As Double
    Private mintUniforme As Double
    Private mintLimpieza As Double
    Private mintVueltas As Double
    Private mintTurnos As Double
    Private mintFrecuencia As Double
    Private mintDisciplina As Double
    Private mintLiquidacio As Double
    Private mdblTotalperi As Double
    Private mintIDEmpleado As Integer

    Public Property idEvaluacionTotales() As Integer
        Get
            Return mintidEvaluacionTotales
        End Get
        Set(ByVal value As Integer)
            mintidEvaluacionTotales = value
        End Set
    End Property
    Public Property Evaluacion() As Integer
        Get
            Return mintEvaluacion
        End Get
        Set(ByVal value As Integer)
            mintEvaluacion = value
        End Set
    End Property
    Public Property Mes() As String
        Get
            Return mstrMes
        End Get
        Set(ByVal value As String)
            mstrMes = value
        End Set
    End Property
    Public Property Anio() As Integer
        Get
            Return mintAnio
        End Get
        Set(ByVal value As Integer)
            mintAnio = value
        End Set
    End Property
    Public Property Licencia() As Double
        Get
            Return mintLicencia
        End Get
        Set(ByVal value As Double)
            mintLicencia = value
        End Set
    End Property
    Public Property Tarjeton() As Double
        Get
            Return mintTarjeton
        End Get
        Set(ByVal value As Double)
            mintTarjeton = value
        End Set
    End Property
    Public Property Uniforme() As Double
        Get
            Return mintUniforme
        End Get
        Set(ByVal value As Double)
            mintUniforme = value
        End Set
    End Property
    Public Property Limpieza() As Double
        Get
            Return mintLimpieza
        End Get
        Set(ByVal value As Double)
            mintLimpieza = value
        End Set
    End Property
    Public Property Vueltas() As Double
        Get
            Return mintVueltas
        End Get
        Set(ByVal value As Double)
            mintVueltas = value
        End Set
    End Property
    Public Property Turnos() As Double
        Get
            Return mintTurnos
        End Get
        Set(ByVal value As Double)
            mintTurnos = value
        End Set
    End Property
    Public Property Frecuencia() As Double
        Get
            Return mintFrecuencia
        End Get
        Set(ByVal value As Double)
            mintFrecuencia = value
        End Set
    End Property
    Public Property Disciplina() As Double
        Get
            Return mintDisciplina
        End Get
        Set(ByVal value As Double)
            mintDisciplina = value
        End Set
    End Property
    Public Property Liquidacio() As Double
        Get
            Return mintLiquidacio
        End Get
        Set(ByVal value As Double)
            mintLiquidacio = value
        End Set
    End Property
    Public Property IDEmpleado() As Integer
        Get
            Return mintIDEmpleado
        End Get
        Set(ByVal value As Integer)
            mintIDEmpleado = value
        End Set
    End Property
    Public Property Total() As Double
        Get
            Return mdblTotalperi
        End Get
        Set(ByVal value As Double)
            mdblTotalperi = value
        End Set
    End Property

    Public Sub New()
        mintidEvaluacionTotales = 0
        mintEvaluacion = 0
        mstrMes = ""
        mintAnio = 0
        mintLicencia = 0
        mintTarjeton = 0
        mintUniforme = 0
        mintLimpieza = 0
        mintVueltas = 0
        mintTurnos = 0
        mintFrecuencia = 0
        mintDisciplina = 0
        mdblTotalperi = 0
        mintIDEmpleado = 0
    End Sub
    Public Sub Borrar()
        Call SetSqlCitra("Delete From EvaluacionOLDTotales Where idempleado = " & IDEmpleado & " and mes='" & Mes & "'" & " and anio=" & Anio)

    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into EvaluacionOLDTotales (" & _
                            "IdEvaluacionTotales," & _
                            "IdEmpleado," & _
                            "Evaluacion," & _
                            "Mes," & _
                            "Anio," & _
                            "Licencia," & _
                            "Tarjeton," & _
                            "Uniforme," & _
                            "Limpieza," & _
                            "Vueltas," & _
                            "Turnos," & _
                            "Frecuencia," & _
                            "Disciplina," & _
                            "Total," & _
                            "Liquidacion)" & _
                            "VALUES (" & _
                            "@IdEvaluacionTotales," & _
                            "@IdEmpleado," & _
                            "@Evaluacion," & _
                            "substring(@Mes,1,20)," & _
                            "@Anio," & _
                            "@Licencia," & _
                            "@Tarjeton," & _
                            "@Uniforme," & _
                            "@Limpieza," & _
                            "@Vueltas," & _
                            "@Turnos," & _
                            "@Frecuencia," & _
                            "@Disciplina," & _
                            "@Total," & _
                            "@Liquidacion)"

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdEvaluacionTotales", mintidEvaluacionTotales)
        Command.Parameters.AddWithValue("IdEmpleado", mintIDEmpleado)
        Command.Parameters.AddWithValue("Evaluacion", mintEvaluacion)
        Command.Parameters.AddWithValue("Mes", mstrMes)
        Command.Parameters.AddWithValue("Anio", mintAnio)
        Command.Parameters.AddWithValue("Licencia", mintLicencia)
        Command.Parameters.AddWithValue("Tarjeton", mintTarjeton)
        Command.Parameters.AddWithValue("Uniforme", mintUniforme)
        Command.Parameters.AddWithValue("Limpieza", mintLimpieza)
        Command.Parameters.AddWithValue("Vueltas", mintVueltas)
        Command.Parameters.AddWithValue("Turnos", mintTurnos)
        Command.Parameters.AddWithValue("Frecuencia", mintFrecuencia)
        Command.Parameters.AddWithValue("Disciplina", mintDisciplina)
        Command.Parameters.AddWithValue("Liquidacion", mintLiquidacio)
        Command.Parameters.AddWithValue("Total", mdblTotalperi)


        cnConn.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Command.ExecuteNonQuery
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Aviso")
        End Try

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar la evaluacion", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
